import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '品牌',
    align: "center",
    dataIndex: 'brand'
  },
  {
    title: '车型',
    align: "center",
    dataIndex: 'vehicleModel'
  },
  {
    title: '款式',
    align: "center",
    dataIndex: 'style'
  },
  {
    title: '车牌号码',
    align: "center",
    dataIndex: 'carNumber'
  },
  {
    title: '车辆识别代码',
    align: "center",
    dataIndex: 'vehicleNumber'
  },
  {
    title: '发动机号',
    align: "center",
    dataIndex: 'engineNumber'
  },
  {
    title: '车辆类型',
    align: "center",
    dataIndex: 'vehicleType_dictText'
  },
  {
    title: '使用性质',
    align: "center",
    dataIndex: 'carFunction_dictText'
  },
  {
    title: '注册日期',
    align: "center",
    dataIndex: 'registrationDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '发证日期',
    align: "center",
    dataIndex: 'openingDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '交强险投保日期',
    align: "center",
    dataIndex: 'insuranceDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "创建人",
    field: 'createBy',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "品牌",
    field: 'brand',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "车牌号码",
    field: 'carNumber',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "发动机号",
    field: 'engineNumber',
    component: 'Input',
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '品牌',
    field: 'brand',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入品牌!'},
             ];
    },
  },
  {
    label: '车型',
    field: 'vehicleModel',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入车型!'},
             ];
    },
  },
  {
    label: '款式',
    field: 'style',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入款式!'},
             ];
    },
  },
  {
    label: '车牌号码',
    field: 'carNumber',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入车牌号码!'},
             ];
    },
  },
  {
    label: '车辆识别代码',
    field: 'vehicleNumber',
    component: 'Input',
  },
  {
    label: '发动机号',
    field: 'engineNumber',
    component: 'Input',
  },
  {
    label: '车辆类型',
    field: 'vehicleType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "vehicle_type"
    },
  },
  {
    label: '使用性质',
    field: 'carFunction',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "car-function"
    },
  },
  {
    label: '注册日期',
    field: 'registrationDate',
    component: 'DatePicker',
  },
  {
    label: '发证日期',
    field: 'openingDate',
    component: 'DatePicker',
  },
  {
    label: '交强险投保日期',
    field: 'insuranceDate',
    component: 'DatePicker',
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
